package com.hyzh.latte.demo.consts;


import lombok.Getter;

/**
 * @Author: WangLong
 * @Description: 枚举类
 * @CreateTime: 2024-03-22 10:58
 */
public class GateCommonEnums {

    /**
     * 审核状态
     */
    public enum CheckStatus{

        UNAPPROVED(0, "未审批"),
        CONSENT(1, "通过"),
        REFUSE(2, "拒绝"),;
        @Getter
        private Integer code;
        @Getter
        private String value;

        CheckStatus(Integer code, String value) {
            this.code = code;
            this.value = value;
        }

        /**
         * 根据value获取code
         * @param value
         * @return
         */
        public static Integer getKey(String value){
            if (value == null){
                return null;
            }
            for (CheckStatus item : values()) {
                if (value.equals(item.value)) {
                    return item.code;
                }
            }
            return null;
        }

        /**
         * 根据key获取value
         * @param key
         * @return
         */
        public static String getValue(Integer key){
            if (key == null){
                return null;
            }
            for (CheckStatus item : values()){
                if (key.equals(item.code)){
                    return item.value;
                }
            }
            return null;
        }
    }


    /**
     * 入园
     */
    public enum InRecord{

        IN_PERSONNEL(1, "人员"),
        IN_ORDINARY_VEHICLE(2, "普通车辆"),
        IN_HAZARDOUS_CHEMICAL_VEHICLES(3, "危化品车辆");
        @Getter
        private Integer code;
        @Getter
        private String value;

        InRecord(Integer code, String value) {
            this.code = code;
            this.value = value;
        }

        /**
         * 根据value获取code
         * @param value
         * @return
         */
        public static Integer getKey(String value){
            if (value == null){
                return null;
            }
            for (InRecord item : values()) {
                if (value.equals(item.value)) {
                    return item.code;
                }
            }
            return null;
        }

        /**
         * 根据key获取value
         * @param key
         * @return
         */
        public static String getValue(Integer key){
            if (key == null){
                return null;
            }
            for (InRecord item : values()){
                if (key.equals(item.code)){
                    return item.value;
                }
            }
            return null;
        }
    }


    /**
     * 出园
     */
    public enum OutRecord{

        OUT_PERSONNEL(1, "人员"),
        OUT_ORDINARY_VEHICLE(2, "普通车辆"),
        OUT_HAZARDOUS_CHEMICAL_VEHICLES(3, "危化品车辆");
        @Getter
        private Integer code;
        @Getter
        private String value;

        OutRecord(Integer code, String value) {
            this.code = code;
            this.value = value;
        }

        /**
         * 根据value获取code
         * @param value
         * @return
         */
        public static Integer getKey(String value){
            if (value == null){
                return null;
            }
            for (OutRecord item : values()) {
                if (value.equals(item.value)) {
                    return item.code;
                }
            }
            return null;
        }

        /**
         * 根据key获取value
         * @param key
         * @return
         */
        public static String getValue(Integer key){
            if (key == null){
                return null;
            }
            for (OutRecord item : values()){
                if (key.equals(item.code)){
                    return item.value;
                }
            }
            return null;
        }
    }

    /**
     * 报警统计
     */
    public enum Warning{

        WEITING(1, "违停"),
        CHAOSU(2, "超速"),
        BUANGUIDAOXINGSHI(3, "不按轨道行驶"),
        YUEJIE(4, "越界"),
        YANWU(5, "烟雾"),
        HUOZAI(6, "火灾"),
        PENGZHUANG(7, "碰撞");
        @Getter
        private Integer code;
        @Getter
        private String value;

        Warning(Integer code, String value) {
            this.code = code;
            this.value = value;
        }

        /**
         * 根据value获取code
         * @param value
         * @return
         */
        public static Integer getKey(String value){
            if (value == null){
                return null;
            }
            for (Warning item : values()) {
                if (value.equals(item.value)) {
                    return item.code;
                }
            }
            return null;
        }

        /**
         * 根据key获取value
         * @param key
         * @return
         */
        public static String getValue(Integer key){
            if (key == null){
                return null;
            }
            for (Warning item : values()){
                if (key.equals(item.code)){
                    return item.value;
                }
            }
            return null;
        }
    }
}
